<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath }" var="baseUrl"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>众筹管理后台</title>
		<link rel="stylesheet" href="../admin/css/bootstrap.min.css" />
		<link rel="stylesheet" href="../admin/css/dashboard.css" />
	</head>
	<body>
		
		 <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">众筹管理平台</a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
        	
          <ul class="nav navbar-nav navbar-right">
          	<li><a href="index.jsp">首页</a></li>
          	<li><a href="#">欢迎, ${admin1.adminName }</a></li>
            <li><a href="#" title="修改个人资料和密码的页面">设置</a></li>
            <li><a href="${baseUrl }/AdminController/outAdmin" title="退出登录">退出</a></li>
          </ul>
        </div>
      </div>
    </nav>

    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
        	<ul class="nav nav-sidebar">
            <li ><a href="index.jsp">首页</a></li>
           </ul>
          <ul class="nav nav-sidebar">
            <li class="active"><a href="${baseUrl }/AdminController/getAllProjects">所有项目*</a></li>
            <li><a href="#">项目审核</a></li>
            <li><a href="#">项目跟踪</a></li>
            <li><a href="#">项目评论</a></li>
            <li><a href="classify/all_classity.jsp">项目分类*</a></li>
            <li><a href="#">项目推荐</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="">注册用户</a></li>
            <li><a href="">用户资金</a></li>
            <li><a href="">用户日志</a></li>
            <li><a href="">实名审核</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="">新闻管理</a></li>
            <li><a href="">问题管理</a></li>
            <li><a href="">管理用户</a></li>
            <li><a href="">管理日志</a></li>
          </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
          <h1 class="page-header">所有众筹项目</h1>

		<div class="panel panel-default">
  <div class="panel-body">
			<form class="form-inline">
			  <div class="form-group">
			    <input type="text" class="form-control" name="proName" value="${proName }" id="exampleInputName2" placeholder="项目名称">
			  </div>
			   <div class="form-group">
			    <input type="text" class="form-control" name="userName" value="${userName }" id="exampleInputName2" placeholder="项目发起人">
			  </div>
			  <div class="form-group">
			   <select class=form-control name="proStatus" id="proStatus">
			   	<option value="">项目状态</option>
			   	<option value="0">待审核</option>
			   	<option value="1">待上架</option>
			   	<option value="2">众筹中</option>
			   	<option value="3">众筹失败</option>
			   	<option value="4">众筹成功</option>
			   	<option value="5">审核未通过</option>
			   </select>
			  </div>
			   <div class="form-group">
			   <select class=form-control name="proType" id="proType"> 
			   	<option value="">项目类型</option>
			   	<option value="1">教育助学</option>
			   	<option value="2">爱心环保</option>
			   	<option value="3">扶贫助困</option>
			   	<option value="4">公益创业</option>
			   	<option value="5">公益活动</option>
			   </select>
			  </div>
			  &nbsp;&nbsp;
			  <button type="submit" class="btn btn-default btn-primary">查询</button>
			</form>
    </div>
   </div>
			<div class="panel panel-default">
  <div class="panel-heading">
    <div class="panel-title">
    	所有项目列表
    </div>
  </div>
  <div class="panel-body" id="projectDiv">
   
          <div class="table-responsive ">
            <table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th>序号</th>
                  <th>项目类型</th>
                  <th>项目名称</th>
                  <th>项目进度</th>
                  <th>开始日期</th>
                  <th>结束日期</th>
                  <th>已筹金额</th>
                  <th>发起人</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
              <c:forEach items="${list }" var="project">
                <tr>
                  <c:set value="${i+1 }" var="i"></c:set>
                  <td>${i }</td>
                  <td>${project.bft.bftpName }</td>
                  <td>${project.psName }</td>
                  <td>80%</td>
                  <td>${project.psStarttime }</td>
                  <td>${project.psEndtime }</td>
                  <td>${project.psGetmoney }￥</td>
                  <td>${project.user.usName }</td>
                  <td>
                  	<a href="${baseUrl }/ProjectsController/getProjectsDetail?id=${project.psId}">详情</a>
                  	<!--<a href="#" title="查看项目详情"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></a>-->
                  	<!--&nbsp;&nbsp;
                  	<a href="#" title="编辑项目信息"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a>-->
                  </td>
                </tr>
              </c:forEach>  
               
              </tbody>
            </table>
          </div>

		<!-- 传递参数 -->
		<c:url value="AdminController/getAllProjects" var="first">
			<c:param name="pageIndex" value="${pageIndexFlag }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
		<c:url value="AdminController/getAllProjects" var="second">
			<c:param name="pageIndex" value="${pageIndexFlag+1 }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
		<c:url value="AdminController/getAllProjects" var="three">
			<c:param name="pageIndex" value="${pageIndexFlag+2 }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
		<c:url value="AdminController/getAllProjects" var="four">
			<c:param name="pageIndex" value="${pageIndexFlag+3 }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
		<c:url value="AdminController/getAllProjects" var="five">
			<c:param name="pageIndex" value="${pageIndexFlag+4 }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
		<c:url value="AdminController/getAllProjects" var="previous">
			<c:param name="pageIndex" value="${pageIndex - 1 }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
		<c:url value="AdminController/getAllProjects" var="next">
			<c:param name="pageIndex" value="${pageIndex + 1 }"></c:param>
			<c:param name="proName" value="${proName }"></c:param>
			<c:param name="userName" value="${userName }"></c:param>
			<c:param name="pageIndexFlag" value="${pageIndexFlag }"></c:param>
			<c:param name="proStatus" value="${proStatus }"></c:param>
			<c:param name="proType" value="${proType }"></c:param>
		</c:url>
  	             <nav aria-label="Page navigation" class="text-right">
				  <ul class="pagination">
				    <li >
				      <a <c:if test="${pageIndex>1 }"> href="${baseUrl }/${previous}"  </c:if> aria-label="Previous" id="a1">
				        <span aria-hidden="true">&laquo;上一页</span>
				      </a>
				    </li>
				    <li  <c:if test="${pageIndex==pageIndexFlag }"> class="active"</c:if> ><a href="${baseUrl }/${first }" class="pageIndex">${pageIndexFlag }</a></li>
				    <li <c:if test="${pageIndex==pageIndexFlag+1 }"> class="active"</c:if> ><a href="${baseUrl }/${second }" class="pageIndex">${pageIndexFlag+1 }</a></li>
				    <li <c:if test="${pageIndex==pageIndexFlag+2 }"> class="active"</c:if> ><a href="${baseUrl }/${three }" class="pageIndex">${pageIndexFlag+2 }</a></li>
				    <li <c:if test="${pageIndex==pageIndexFlag+3 }"> class="active"</c:if> ><a href="${baseUrl }/${four }" class="pageIndex">${pageIndexFlag+3 }</a></li>
				    <li <c:if test="${pageIndex==pageIndexFlag+4 }"> class="active"</c:if> ><a href="${baseUrl }/${five}"  id="pageIndexEnd" class="pageIndex">${pageIndexFlag+4 }</a></li>
				    <li class=""><a href="">...</a></li>
				    <li>
				      <a <c:if test="${pageIndex < totalPages }">href="${baseUrl }/${next }"</c:if> aria-label="Next" id="a2">
				        <span aria-hidden="true">下一页&raquo;</span>
				      </a>
				    </li>
				    <br><br>
				    <li>
						<form action="${baseUrl }/AdminController/getAllProjects">
						共${totalPages }页&nbsp;
							到第<input type="number" min="1" max="${totalPages }" name="pageIndex" value="${pageIndex }">页
							<input type="hidden" value="${pageIndexFlag }" name="pageIndexFlag">
							<input type="hidden" value="${proName }" name="proName" >
							<input type="hidden" value="${userName }" name="userName" >
							<input type="hidden" value="${proStatus }" name="proStatus" >
							<input type="hidden" value="${proType }" name="proType" >
							&nbsp;
							<input type="submit" value="确定">
						</form>
					</li>
				  </ul>
				</nav>   	
  </div>
 

</div>
      
        </div>
      </div>
    </div>
		
		<script type="text/javascript" src="../admin/js/jquery1.12.4.min.js" ></script>
		<script type="text/javascript" src="../admin/js/bootstrap.min.js" ></script>
		<script type="text/javascript" src="../admin/js/countUp.js" ></script>
		<script>
		var pageIndex=${pageIndex};
		var pageIndexEnd=$('#pageIndexEnd').html();
		
			$(function(){
				var proStatus = ${proStatus}
				var proType = ${proType}
				$("#proStatus option").each(function(){
					if($(this).val()==proStatus){
						$(this).attr("selected",true)
					}
				});
				$("#proType option").each(function(){
					if($(this).val()==proType){
						$(this).attr("selected",true)
					}
				});
				
				if(pageIndex+1>pageIndexEnd){
					$(".pageIndex").each(function(){
						var pageIndexOld=$(this).text();
						var pageIndexNew=$(this).html(parseInt(pageIndexOld)+1);
						/* $("pageIndex").setAttribute("value",pageIndexNew); */
					})
				}
				if(pageIndex==pageIndexEnd-4&&pageIndex!=1){
					$(".pageIndex").each(function(){
						var pageIndexOld=$(this).text();
						var pageIndexNew=$(this).html(parseInt(pageIndexOld)-1);
						/* $("pageIndex").setAttribute("value",pageIndexNew); */
					})
				}
			})
		</script>
	</body>
</html>
